#ifndef __J1939_DIAG_H__
#define __J1939_DIAG_H__

#include "comm_typedef.h"

/*PGN definition*/

#define J1939_DM01_PGN 65226

/* J1939 DTC
 *
 * bit 0-15  :Suspect Parameter Number(SPN)
 * bit 16-20 : Failure Mode Indicator(FMI)
 * bit 21-23 :Suspect Parameter Number(SPN)
 * bit 24-30 : Occurrence Count(OC)
 * bit 31	 : SPN Conversion Method(CM)
 */
#define GET_DM01_SPN(dtc) (((dtc)&0xFFFF) | (((dtc) >> 21 & 0x7) << 16))
#define GET_DM01_FMI(dtc) (((dtc) >> 16 & 0x1f))
#define GET_DM01_OC(dtc) (((dtc) >> 24 & 0x7f))
#define GET_DM01_CM(dtc) (((dtc) >> 31 & 0x1))
typedef uint32_t j1939_dtc_t;
/*
 * bit 0-1:protectLampSts:2;
 * bit 2-3:amberWarningLampStatus:2;
 * bit 4-5:redStopLampStatus:2;
 * bit 6-7：malfunctionIndicatorLampSts:2;
 */
#define GET_DM01_PROTECT_LAMP(data) ((data)&0x3)
#define GET_DM01_AMBERWARNING_LAMP(data) (((data) >> 2 & 0x3))
#define GET_DM01_REDSTOP_LAMP(data) (((data) >> 4 & 0x3))
#define GET_DM01_MALFUNCTION_LAMP(data) (((data) >> 6 & 0x3))
#endif
